$solutionName = "EFSPWebParts.ListViewNoHeader.wsp"

$sol = Get-SPSolution | Where-Object {$_.Name -eq $solutionName}
if ($sol -ne $null) {
	if($sol.Deployed -eq $true)
	{	
		Uninstall-SPSolution -Identity $solutionName -Confirm:$false
		write-host "uninstalling $($solutionName) ..." -NoNewline
		do 
		{ 
			Write-Host "." -NoNewline
			Start-Sleep 1
		}
		while ((Get-SPSolution $solutionName).JobExists -eq $true)
		Write-Host "ok"
	}
	else
	{
		Write-Host "Solution $($solutionName) not deployed"
	}
	
	if($sol.Deployed -eq $false)
	{
		write-host "removing $($solutionName) ..."
		Remove-SPSolution -Identity $solutionName -Confirm:$false
	}
	else
	{
		$sol2 = Get-SPSolution $solutionName
		Write-Host "test"
	}
}
else
{
	Write-Host "Solution $($solutionName) not installed"
}
	
